﻿

using bpms.Dao;
using bpms.Models;

namespace bpms.Service
{
    /// <summary>
    /// 管理员模块业务逻辑类
    /// </summary>
    public class AdminUserService
    {
        private readonly AdminUserDao adminUserDao;
        public AdminUserService(AdminUserDao dao)
        {
            adminUserDao = dao;
        }

        /// <summary>
        /// 查询所有管理员用户
        /// </summary>
        /// <returns></returns>
        public List<AdminUser> GetAll()
        {
            return adminUserDao.GetAll();
        }

        /// <summary>
        /// 根据Id查询管理员用户
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public AdminUser GetById(int id)
        {
            return adminUserDao.GetById(id);
        }

        /// <summary>
        /// 根据登录名查询管理员用户
        /// </summary>
        /// <param name="loginName"></param>
        /// <returns></returns>
        public AdminUser GetByLoginName(string loginName)
        {
            return adminUserDao.GetByLoginName(loginName);
        }

        /// <summary>
        /// 根据登录名和密码查询管理员用户
        /// </summary>
        /// <param name="loginName"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public AdminUser GetAdminByLoginNameAndPwd(string loginName, string password)
        {
            return adminUserDao.GetAdminByLoginNameAndPwd(loginName,password);
        }

        /// <summary>
        /// 更新管理员用户
        /// </summary>
        /// <param name="admin"></param>
        /// <returns></returns>
        public int update(AdminUser admin)
        {
            return adminUserDao.update(admin);
        }

        /// <summary>
        /// 添加管理员用户
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Add(AdminUser model)
        {
            return adminUserDao.Add(model);
        }
    }
}
